package com.example.module_motorcircle.motor_circle.viewmodel

import com.example.lib_common.base.BaseViewModel
import com.example.lib_common.state.UIState
import com.example.lib_common.utils.ToastUtils
import com.example.lib_net.model.api.PostItem
import com.example.lib_net.model.api.PostModel
import com.example.module_motorcircle.motor_circle.model.MotorCircleNavigationItem
import com.example.module_motorcircle.motor_circle.repository.MotorCircleRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

/**
 * @author yaotianxue
 * @description
 * @date 2025/2/11
 */
@HiltViewModel
class MotorCircleViewModel @Inject constructor(private val repository: MotorCircleRepository):BaseViewModel() {
    //导航数据
    var tabs = mutableListOf<MotorCircleNavigationItem>()
    //导航状态
    private val navigationState = MutableStateFlow<UIState>(UIState.Default)
    val navigationState_ = navigationState.asStateFlow()
    /**
     * 获得导航数据
     */
    fun getNavigationItem(){
        execute(
            action = repository.getNavigationItem(),
            onFinished = {
                tabs = it.data
                navigationState.value = UIState.Success
            }
        )
    }




}